package de.fuberlin.inf.alp4.uebg5;

import java.util.concurrent.Callable;

/**
 * This class represents MessageRequests which may be waiting for
 * some other MessageRequests to free their guard
 * @author reim
 *
 */
public final class M1Request extends MessageRequest<Integer> {

    /* The request might hold attributes for the parameter and
       the method <code>guard()</code> may be overridden here.

        The constructor initialises the servant field provided in the super
        class and creates a new callable instance, that, on dispatch, calls
        its method on the servant object. This is convenient, because
        a conventional object may be converted to an active one with minimal
        effort. */
    public M1Request(final Servant servant, int priority) {
		super(servant, 
				new Callable<Integer>() {
	                           public Integer call() { return servant.m1(); }
	            }, priority);
    }

	public boolean guard() {
		return (this.servant.m1() > 50);
	}
	
	public String getRequestType() {
		return "M1";
	}
    
}
